package com.example.car.manager.ui.chezhoubian;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.car.R;
import com.example.car.bean.Discuss;
import com.example.car.bean.Inform;
import com.example.car.manager.BaseFragment;
import com.example.car.manager.utils.HttpAll;
import com.example.car.manager.utils.HttpHelper;
import com.example.car.manager.utils.NetWorkUtil;

public class AroundCar extends BaseFragment {
	public static final String URLDE="http://www.51wits.com/discuss.php";
	LinearLayout view;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View v=inflater.inflate(R.layout.aroundcar, container,false);
		inti(v);
		 if(NetWorkUtil.GetConnect(hodler)!=0){
			 getData(inflater, container);
		 }else{
			 
		 }
		
		
		return v;
	}
	

	@SuppressWarnings("unchecked")
	private void getData(final LayoutInflater inflater,
			final ViewGroup container) {
		new HttpAll(URLDE).toJson(new HttpHelper<Discuss>(new Discuss()) {
			@Override
			public void delevery(boolean IsSuccuss, Discuss resolve) {
				int length = resolve.list.size();
				for (int i = 0; i < length; i++) {
					TextView text = createTextView();
					text.setText(resolve.list.get(i).getToast());
					view.addView(text);
					// TextView
					// text=(TextView)inflater.inflate(R.layout.textview,container);
					// text.setText(resolve.list.get(0).getToast());
					// view.addView(text);
				}

			}

		});

	}

	void inti(View v) {
		view = (LinearLayout) v.findViewById(R.id.taolun);

	}

	@SuppressLint({ "NewApi", "ResourceAsColor" })
	private TextView createTextView() {
		TextView text = new TextView(hodler);
		text.setBackgroundResource(R.drawable.daijia);
		text.setPadding(25, 15, 25, 10);
		text.setTextColor(R.color.TextColorWhite);
		text.setGravity(Gravity.CENTER);
		LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
		params.setMargins(25, 25, 25, 25);
		text.setLayoutParams(params);
		return text;
	}

}
